package com.easy.service.impl;

import com.easy.bean.UserAddress;
import com.easy.dao.UserAddressDao;
import com.easy.service.IUserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserAddressServiceImpl implements IUserAddressService {

    @Autowired
    UserAddressDao userAddressDao;

    @Override
    public int add(UserAddress address) {
        return userAddressDao.add(address);
    }

    @Override
    public int edit(UserAddress address) {
        return userAddressDao.edit(address);
    }

    @Override
    public int delete(int id) {
        return userAddressDao.delete(id);
    }

    @Override
    public UserAddress getAddressByID(int id) {
        return userAddressDao.getAddressByID(id);
    }

    @Override
    public List<UserAddress> getAddressByUserID(int userid) {
        return userAddressDao.getAddressByUserID(userid);
    }

    @Override
    @Transactional
    public int setDefault(int userid,int id) {
        userAddressDao.cancelDefault(userid);
       return userAddressDao.setDefault(id);
    }
}
